import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while(in.hasNextInt()){
            int n = in.nextInt();
            int[] cost = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                cost[i] = in.nextInt();
            }
            int ret = searchMin(cost,n);
            System.out.println(ret);
        }
    }
    private static int searchMin(int[] cost,int n){
        int[] dp = new int[n + 1];
        dp[0] = dp[1] = 0;
        for (int i = 2;i <= n;i ++){
            dp[i] = Math.min(dp[i - 1] + cost[i - 1],dp[i - 2] + cost[i - 2]);
        }
        return dp[n];
    }
}